<?php
App::uses('AppModel', 'Model');
/**
 * Character Model
 *
 * @property Player $Player
 * @property LogLine $LogLine
 * @property Event $Event
 * @property Item $Item
 * @property Power $Power
 * @property Skill $Skill
 */
class Character extends AppModel {
/**
 * Validation rules
 *
 * @var array
 */
	public $validate = array(
		'player_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'Relationship ID\'s must be numberic',
			),
		),
		'chin' => array(
			'naturalNumber' => array(
				'rule' => 'naturalNumber',
				'message' => 'CHaracter Identification Number is required',
			),
		),
		'xp' => array(
			'decimal' => array(
				'rule' => array('decimal', 0),
				'message' => 'XP can only be an integer or decimal',
			),
		),
		'name' => array(
			'notEmpty' => array(
				'rule' => 'notEmpty',
				'message' => 'All characters must have a name',
			),
		),
		'faction' => array(
			'allowedChoice' => array(
				'rule' => array('inList', array('Ent','Gargoyle','Golem','Leviathan','Naga','Phoenix','Unicorn','Wyvern')),
				'message' => 'Faction can only be one of the eight factions.',
				'allowEmpty' => true,
			),
		),
		'element' => array(
			'allowedChoice' => array(
				'rule' => array('inList', array('Air','Earth','Fire','Metal','Water','Wood')),
				'message' => 'Element can only be one of the six factions.',
				'allowEmpty' => true,
			),
		),
		'faith' => array(),
		'group' => array(),
// TODO: fix status validation
		'status' => array(
			'allowedChoice' => array(
				'rule' => array('inList', array('Active','Inactive','Deceased')),
			),
		),
		'comments' => array(),
		'deleted' => array(
			'boolean' => array(
				'rule' => array('boolean'),
				'message' => 'You should not be seeing this message. Deleted should be true or false.',
			),
		),
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'Player' => array(
			'className' => 'Player',
			'foreignKey' => 'player_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

/**
 * hasMany associations
 *
 * @var array
 */
	public $hasMany = array(
		'LogLine' => array(
			'className' => 'LogLine',
			'foreignKey' => 'character_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);


/**
 * hasAndBelongsToMany associations
 *
 * @var array
 */
	public $hasAndBelongsToMany = array(
		'Event' => array(
			'className' => 'Event',
			'joinTable' => 'characters_events',
			'foreignKey' => 'character_id',
			'associationForeignKey' => 'event_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Item' => array(
			'className' => 'Item',
			'joinTable' => 'characters_items',
			'foreignKey' => 'character_id',
			'associationForeignKey' => 'item_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Power' => array(
			'className' => 'Power',
			'joinTable' => 'characters_powers',
			'foreignKey' => 'character_id',
			'associationForeignKey' => 'power_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Skill' => array(
			'className' => 'Skill',
			'joinTable' => 'characters_skills',
			'foreignKey' => 'character_id',
			'associationForeignKey' => 'skill_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);

}
